
function! plugin#vim_projectroot#load() abort
    if !exists('g:loaded_projectroot')
        packadd vim-projectroot
    endif
    return exists('g:loaded_projectroot')
endfunction

function! plugin#vim_projectroot#init() abort
    if plugin#vim_projectroot#load()
        let g:leader_keymap = get(g:, 'leader_keymap', { 'name': '+leader' })
        let g:projectroot_keymap = get(g:, 'projectroot_keymap', { 'name': '+projectroot' ,
                    \ 'x': [':call feedkeys(":ProjectRootExe ","")'   , 'execute'     ],
                    \ '.': [':ProjectRootCD'    , 'cd'          ],
                    \ 'n': [':ProjectBufNext'   , 'next'        ],
                    \ 'p': [':ProjectBufPrev'   , 'previous'    ],
                    \ 'f': [':ProjectBufFirst'  , 'first'       ],
                    \ 'l': [':ProjectBufLast'   , 'last'        ],
                    \ })
        let g:leader_keymap.p = g:projectroot_keymap
        autocmd BufEnter * ProjectRootCD
    endif
    " nnoremap <Leader>g :ProjectRootExe grep<space>
    " nnoremap <leader>dp :ProjectRootCD<cr>
    " nnoremap <leader>ep :ProjectRootCD<cr>:e<space>
    " nnoremap <expr> <leader>eP ':e '.projectroot#guess().'/'
    " nnoremap <silent> <leader>ef :exe 'CtrlP' projectroot#guess("'F")<cr>
    " nnoremap <silent> <leader>eg :exe 'CtrlP' projectroot#guess()<cr>
    " nnoremap <silent> [p :ProjectBufPrev<cr>
    " nnoremap <silent> ]p :ProjectBufNext<cr>
    " nnoremap <silent> [P :ProjectBufFirst<cr>
    " nnoremap <silent> ]P :ProjectBufLast<cr>
    " nnoremap <silent> ]v :ProjectBufNext ~/.vim<cr>
    " nnoremap <silent> [v :ProjectBufPrev ~/.vim<cr>
    " nnoremap <silent> ]f :ProjectBufNext 'F<cr>
    " nnoremap <silent> [f :ProjectBufPrev 'F<cr>
    " nnoremap <silent> <F9> :ProjectRootExe NERDTreeFind<cr>
endfunction





